<template>
  <div class="weekly">
    <div class="content">
      <img
        width="100%"
        src="https://link-wechat-1251309172.cos.ap-nanjing.myqcloud.com/2023-05-18/t1684393733533-TpYSpO5Oa7KAxzpV.png"
        alt=""
      />
      <span class="text">{{ form.weeklyTime }}</span>
    </div>
    <div class="title">
      <div class="line"></div>
      本周数据总览
    </div>
    <div class="data-con">
      <div class="con">
        <div class="sub-title">本周督导成员数</div>
        <van-divider :style="{ color: '#E5E6EB;', borderColor: '#E5E6EB', padding: '16px 0 22px 0', margin: '0' }">
        </van-divider>
        <div class="value">{{ form.staffNum }}<span class="uni">人</span></div>
      </div>
    </div>
    <div class="title">
      <div class="line"></div>
      质检会话总数
    </div>
    <div class="data-con">
      <div class="con">
        <div class="sub-title">本周共产生了</div>
        <van-divider :style="{ color: '#E5E6EB;', borderColor: '#E5E6EB', padding: '16px 0 22px 0', margin: '0' }">
        </van-divider>
        <div style="display: flex;">
          <div class="value state">{{ form.chatNum }}<span class="uni">客户会话数</span></div>
          <div class="value state">{{ form.groupChatNum }}<span class="uni">客群会话数</span></div>
        </div>
      </div>
    </div>
    <div class="title">
      <div class="line"></div>
      质检效率总览
    </div>
    <div class="data-con">
      <div class="con">
        <div style="display: flex;">
          <div class="value state">{{ form.replyNum }}<span class="uni">成员回复次数</span></div>
          <div class="value state">{{ form.timeOutNum }}<span class="uni">成员超时次数</span></div>
        </div>
        <van-divider :style="{ color: '#E5E6EB;', borderColor: '#E5E6EB', padding: '16px 0 22px 0', margin: '0' }">
        </van-divider>
        <div style="display: flex; justify-content: space-between;">
          <div class="value">
            <div class="uni marbo">成员超时率</div>
            {{ Number(form.timeOutRate) * 100 + '%' }}
          </div>
          <div class="value">
            <div class="uni marbo">客户会话超时率</div>
            {{ Number(form.chatTimeOutRate) * 100 + '%' }}
          </div>
          <div class="value">
            <div class="uni marbo">客群会话超时率</div>
            {{ Number(form.groupChatTimeOutRate) * 100 + '%' }}
          </div>
        </div>
      </div>
    </div>
    <div class="bottom" @click="gotoDetail">查看各成员本周质检详情</div>
  </div>
</template>

<script>
  import { getWeeklyDetail } from '@/api/quality'
  export default {
    name: 'quality-weekly',
    data() {
      return {
        id: '',
        form: {
          weeklyTime: null,
          staffNum: null,
          chatNum: null,
          groupChatNum: null,
          replyNum: null,
          timeOutNum: null,
          timeOutRate: null,
          chatTimeOutRate: null,
          groupChatTimeOutRate: null
        }
      }
    },
    methods: {
      getData() {
        getWeeklyDetail(this.id).then((res) => {
          this.form = res.data
        })
      },
      gotoDetail() {
        this.$router.push({
          name: 'weekly-detail',
          query: {
            id: this.id
          }
        })
      }
    },
    created() {
      this.id = this.$route.query.id
      this.getData()
    }
  }
</script>

<style lang="less" scoped>
  .weekly {
    padding-bottom: 80px;
  }
  .content {
    position: relative;
    .text {
      background: #1d2129;
      box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.302);
      border-radius: 8px 0px 8px 8px;
      padding: 8px 16px;
      text-align: center;
      position: absolute;
      left: 8px;
      top: 56%;
      line-height: 18px;
      font-size: 24px;
      font-family: Roboto-Bold Italic, Roboto;
      font-weight: 700;
      color: #ffffff;
    }
  }
  .title {
    margin-top: 32px;
    display: flex;
    align-items: center;
    font-size: 24px;
    font-weight: 700;
    color: #1d2129;
    .line {
      width: 6px;
      height: 24px;
      background: #07c160;
      margin-right: 10px;
    }
  }
  .data-con {
    margin-top: 24px;
    padding: 0 16px;
    .con {
      background: #ffffff;
      border-radius: 16px;
      border: 1px solid #e5e6eb;
      padding: 24px 20px;
      .sub-title {
        font-size: 16px;
        font-weight: 600;
        color: #4e5969;
      }
      .state {
        flex: 1;
      }
      .value {
        font-size: 32px;
        font-weight: 800;
        color: #1d2129;
        .uni {
          font-size: 12px;
          font-weight: 500;
          color: #4e5969;
          margin-left: 4px;
        }
        .marbo {
          margin-bottom: 8px;
        }
      }
      .mar {
        margin-right: 24px;
      }
    }
  }
  .bottom {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 32px;
    width: 310px;
    height: 48px;
    line-height: 48px;
    text-align: center;
    background: linear-gradient(90deg, #07c160 0%, #90de45 99%);
    box-shadow: 0px 16px 16px 0px rgba(143, 222, 69, 0.302);
    border-radius: 16px 16px 16px 16px;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
  }
</style>
